import { del, get, put } from "../utils/requests";

const userURL = {
  getAllUserInfoURL: "/useredit/alluser",
  getUserInfoByName: "/useredit/getuser",
  setManager: "/useredit/setmanager",
  deleteUser: "/useredit/deleteuser",
  modifyUser: "/useredit/modifyuser",
};

/**
 * 获取所有用户的信息 !!该接口直接返回所有数据
 * @returns {status:string, msg:string, total:number, result:[{userName, userPwd, confirmPwd, email, phone}]}
 */
export function getAllUserInfo() {
  return get(userURL.getAllUserInfoURL);
}

/**
 * 
 * @param {userName:string} userName 
 * @returns {status:string, msg:string, result:[{userName, userPwd, confirmPwd, email, phone}]}
 */    
export function getUserInfoByName(userName) {
  return get(userURL.getUserInfoByName, userName);
}

/**
 * 将用户设为管理员
 * @param {userName:string} userName 
 * @returns {status:string, msg:string, result:[]}
 */
export function setUserManager(userName) {
  return put(userURL.setManager, userName);
}

/**
 * 删除用户
 * @param {userName:string} userName 
 * @returns {status:string, msg:string, result:[]}
 */
export function deleteUser(userName) {
  return del(userURL.deleteUser, userName);
}

/**
 * 用户信息更新
 * @param {userInfo:form} userInfo 
 * @returns {status:string, msg:string, result:[]}
 */
export function modifyUser(userInfo) {
  return put(userURL.modifyUser, userInfo);
}
